﻿
using System;
using QDP.Platform.Silverlight.Storyboards;
namespace QDP.Platform.Silverlight
{
    /// <summary>
    /// 包含加载及卸载动画的组件对象
    /// </summary>
    public class PartControl : PartElement
    {
        /// <summary>
        /// 
        /// </summary>
        public override void Show()
        {
            if (Q.EventMonitor.ResumeShowingEvent(this.WidgetContent, this.Desc.Code) == false)
            {
                IsShowed = true;
                base.Show();
                var store = StoryboardFactory.GetStoryboardStore();
                var story = store.Showing(this.WidgetContent);
                story.Begin();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public override void Close()
        {
            // 触发窗口关闭事件
            if (Q.EventMonitor.ResumeClosingEvent(this.WidgetContent,this.Desc.Code) == false)
            {
                IsShowed = false;
                var store = StoryboardFactory.GetStoryboardStore();
                var story = store.Closing(this.WidgetContent);
                story.Completed += (s, e) =>
                {
                    base.Close();
                };
                story.Begin();
            }
        }
    }
}